/**
 * 
 */
package qy.jalgotrade.broker;

/**
 * @author qy
 *
 */
public class OrderEvent {

	public enum Type {

		// @formatter:off
		SUBMITTED(1), // Order has been submitted.
		ACCEPTED(2), // Order has been acknowledged by the broker.
		CANCELED(3), // Order has been canceled.
		PARTIALLY_FILLED(4), // Order has been partially filled.
		FILLED(5); // Order has been completely filled.
		// @formatter:on

		private int value;

		private Type(int value) {

			this.value = value;
		}

		public int getValue() {

			return value;
		}
	}

	private Order __order;

	private Type __eventType;

	private OrderExecutionInfo __eventInfo;

	public OrderEvent(Order order, Type eventType, OrderExecutionInfo eventInfo) {

		__order = order;
		__eventType = eventType;
		__eventInfo = eventInfo;
	}

	public Order getOrder() {

		return __order;
	}

	public Type getEventType() {

		return __eventType;
	}

	/**
	 * <pre>
	 * This depends on the event type:
	 * ACCEPTED: None
	 * CANCELED: A string with the reason why it was canceled.
	 * PARTIALLY_FILLED: An OrderExecutionInfo instance.
	 * FILLED: An OrderExecutionInfo instance.
	 * </pre>
	 * 
	 * @return
	 */
	public OrderExecutionInfo getEventInfo() {

		return __eventInfo;
	}
}
